package com.itheima.demo05;

import java.math.BigDecimal;

public class BigDecimalTest {
    public static void main(String[] args) {
        BigDecimal bd1 = new BigDecimal(10);
        BigDecimal bd2 = new BigDecimal(3);

        /*BigDecimal add = bd1.add(bd2);
        System.out.println(add);*/

        //BigDecimal divide1 = bd1.divide(bd2);//精确计算，虚拟机停不下来
        BigDecimal divide2 = bd1.divide(bd2, 2, BigDecimal.ROUND_UP);
        BigDecimal divide3 = bd1.divide(bd2, 2, BigDecimal.ROUND_FLOOR);
        BigDecimal divide4 = bd1.divide(bd2, 2, BigDecimal.ROUND_HALF_UP);

        //System.out.println(divide1);
        System.out.println(divide2);
        System.out.println(divide3);
        System.out.println(divide4);
    }
}
